package com.cg.slms.dao;

import java.util.ArrayList;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;

import com.cg.slms.domain.Employee;

public class EmployeeDao implements IEmployeeDao{
	private SqlSessionTemplate sqlSession;
	public SqlSessionTemplate getSqlSession() {
		return sqlSession;
	}
	public void setSqlSession(SqlSessionTemplate sqlSession) {
		this.sqlSession = sqlSession;
	}
	public List<Employee> findEmployee(Employee employee){
		List<Employee> employees=new ArrayList<Employee>();
		employees=sqlSession.selectList("findEmployee", employee);
		return employees;
	}
	//增加
		public boolean addEmployee(Employee employee) {
			int ret=sqlSession.insert("addEmployee", employee);
			if (ret>0) {
				return true;
			} else {
				return false;
			}
		}
		//修改
		public boolean updateEmployee(Employee employee) {
			int ret=sqlSession.update("updateEmployee", employee);
			if (ret>0) {
				return true;
			} else {
				return false;
			}
		}
		//查id
		public Employee findEmployeeById(String id) {
			Employee employee=sqlSession.selectOne("findEmployeeById", id);
			return employee;
		}
		//删除
		public boolean deleteEmployeeById(String id) {
			int ret=sqlSession.delete("deleteEmployeeById", id);
			if (ret>0) {
				return true;
			} else {
				return false;
			}
		}
}
